package linkedList;

public class ListNode {
	 int val;
	 ListNode next;
	 ListNode(int x) { val = x; }
	 
	 
	 
	 public ListNode(int[] nums) {
		 this.val = nums[0];
		 ListNode cur = this;
		 for(int i : nums) {
			 ListNode node = new ListNode(i);
			 cur.next = node;
			 cur = cur.next;
		 }
		 
	 }
	 
	 @Override
	 public String toString() {
		 StringBuilder res = new StringBuilder();
		 ListNode cur = this;
		 while(cur != null) {
			 res.append(cur.val + "->");
			 cur = cur.next;
		 }
		 res.append("NULL");
		 return res.toString();
	 }
}